<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="8">
          <el-form-item label="分配单号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="分配日期" prop="FBILLCREDATE">
            <el-date-picker v-model="dataForm.FBILLCREDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="分配结果">
              <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" disabled>
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

         <el-col :span="8">
          <el-form-item label="研学单号" prop="FSRCNO">
            <el-input v-model="dataForm.FSRCNO"  disabled />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="学校名称">
              <el-select v-model="dataForm.FSCHOOL" placeholder="请选择">
                <el-option
                  v-for="item in options5"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>    
          
          <el-col :span="8">
          <el-form-item label="课程名称" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"  disabled />
          </el-form-item>
        </el-col>

       
        <el-col :span="8">
          <el-form-item label="场地名称" prop="FCLASS">
            <el-input v-model="dataForm.FCLASS"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="学生人数" prop="FNUM">
            <el-input v-model="dataForm.FNUM"   />
          </el-form-item>
        </el-col>
       
        <el-col :span="8">
          <el-form-item label="分配人员" prop="FUSER">
            <el-input v-model="dataForm.FUSER"   />
          </el-form-item>
        </el-col>
        

        <el-col :span="5">
          <el-form-item label="">
            <el-button type="success" icon="el-icon-plus" @click="insert">选择学生</el-button>
            <el-button type="primary" :loading="loading" @click="closePage">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <el-table :data="list" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" width="85"></el-table-column>
      <el-table-column prop="FCLASS" label="班级"  ></el-table-column>
      <el-table-column prop="FCATNO" label="身份证号"  ></el-table-column>
      <el-table-column prop="FCATNAME" label="学生姓名"></el-table-column>
    </el-table>
    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        title: "新增",
        insertorupdate: true,
        dataForm: {
            FBILLNO: "Y241130002", 
            FSRCNO:"Y241130001",
            FBILLCREDATE:"2024-12-13",
            FUSER: "汉武帝",
            FSCHOOL: "闵行春申小学",
            FCATNAME: "上海博物馆研学",
            FPOINT:"上海博物馆",
            FBEGDATE: "2025-03-15",
            FENDDATE:"2025-03-17",
            FCLASS:"201房间",
            FNUM:250,
            FMONEY:"2025-03-10 19:00:08",
            FMEMO: "3天2夜汽车之友",
            FCHECKUSE: "",
            FCHECKDATE: "",
            FNOTE:"",
            FBILLTYPE:"教学申请",
            FBILLSTATE: "申请中"
        },
        rules: {
          FUSERNUMBER:[
            { required: true, message: '请输入学籍号码', trigger: 'blur' },
          ],
          FUSER: [
            { required: true, message: '请输入申请人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入申请理由', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FCLASS": "1班",
                  "FCATNO":"32056320",
                  "FCATNAME": "红孩儿"
                },
                { "FENTRYID":2,
                  "FCLASS": "1班",
                  "FCATNO":"32056321",
                  "FCATNAME": "铁扇公主"
                },
                { "FENTRYID":3,
                  "FCLASS": "1班",
                  "FCATNO":"32056322",
                  "FCATNAME": "牛魔王"
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '1',
          label: '申请中'
        }, {
          value: '2',
          label: '已通过'
        }, {
          value: '3',
          label: '已驳回'
        }],

        //所属校区选择数据
        options2: [{
          value: '1',
          label: '本院人员'
        }, {
          value: '2',
          label: '培训人员'
        }, {
          value: '3',
          label: '外来人员'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      closePage(){
        console.log('关闭弹窗dialog');
        this.visible = false;
      },
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>